package com.atguigu.b_localdatetime;

import java.time.LocalDateTime;

public class Demo2 {
    public static void main(String[] args) {
        //创建时间对象
        LocalDateTime now = LocalDateTime.now();

        //获取
        System.out.println("now.getMonth() = " + now.getMonth());//Oct
        System.out.println("now.getMonthValue() = " + now.getMonthValue());//10

        //加/减
        LocalDateTime plusYears = now.plusYears(-5);
        System.out.println("now = " + now);
        System.out.println("plusYears = " + plusYears);

        LocalDateTime minusDays = now.minusDays(-30);
        System.out.println("minusDays = " + minusDays);//2023-11-08

        //设置 with
        LocalDateTime withYear = now.withYear(1991);
        System.out.println("withYear = " + withYear);
    }
}
